import matplotlib.pyplot as plt
import numpy as np

# 从均匀分布中随机采样
array1 = np.random.uniform(0.1, 5.0, size=(100, 2))
array2 = np.random.uniform(4.1, 7.9, size=(100, 2))
print(array1)
print(array2)

# 保存到本地
np.savetxt('array1.txt', array1, fmt='%f %f', delimiter='\n')
np.savetxt('array2.txt', array2, fmt='%f %f', delimiter='\n')

# 读取数据
arr1 = np.loadtxt('array1.txt')
arr2 = np.loadtxt('array2.txt')
print(type(arr1))
print(arr1[:, 0])
print('arr1[:, 1]', arr1[:, 1])

# 绘制散点图
plt.scatter(arr1[:, 0], arr1[:, 1])
plt.scatter(arr2[:, 0], arr2[:, 1])

# 显示
plt.show()
